package com.snatch.snatchmgr.vo;

import java.util.ArrayList;
import java.util.List;


/**
 * 采集的项  如果滚球标准盘 单式标准盘 滚球波胆
 * @author Administrator
 *
 */
public class SnatchItem {
	private boolean isAuto;
	private String itemName;
	private String itemNameText;
	private String itemType;
	private String itemTypeText;
	private Long sleepTiem;			//采集节点睡眠时间
	private String tactics;  //策略  根据不同的策略选择采集方式。策略可以随机换 
	private int ratioType=0;// 赔率类型(0香港盘 1印尼盘2马来盘3欧盘)
	private int start=0;//0为未启动 1为启动
	private SnatchWeb snatchWeb;
	private SnatchGame snatchGame;
	private List<NodeSnatch> nodelist = new ArrayList<NodeSnatch>();  //已启动的节点
	private Long version;
	private int sumPage = 1;
	private Long dataChangeTiem;
	private Long interval;
	
	
	public String getItemName() {
		return itemName;
	}
	public void setItemName(String itemName) {
		this.itemName = itemName;
	}
	public String getItemNameText() {
		return itemNameText;
	}
	public void setItemNameText(String itemNameText) {
		this.itemNameText = itemNameText;
	}
	public String getItemType() {
		return itemType;
	}
	public void setItemType(String itemType) {
		this.itemType = itemType;
	}
	public String getItemTypeText() {
		return itemTypeText;
	}
	public void setItemTypeText(String itemTypeText) {
		this.itemTypeText = itemTypeText;
	}
	public Long getSleepTiem() {
		return sleepTiem;
	}
	public void setSleepTiem(Long sleepTiem) {
		this.sleepTiem = sleepTiem;
	}
	public String getTactics() {
		return tactics;
	}
	public void setTactics(String tactics) {
		this.tactics = tactics;
	}
	public int getRatioType() {
		return ratioType;
	}
	public void setRatioType(int ratioType) {
		this.ratioType = ratioType;
	}
	public int getStart() {
		return start;
	}
	public void setStart(int start) {
		this.start = start;
	}
	public List<NodeSnatch> getNodelist() {
		return nodelist;
	}
	public void setNodelist(List<NodeSnatch> nodelist) {
		this.nodelist = nodelist;
	}
	public boolean isAuto() {
		return isAuto;
	}
	public void setAuto(boolean isAuto) {
		this.isAuto = isAuto;
	}
	
	public SnatchWeb getSnatchWeb() {
		return snatchWeb;
	}
	public void setSnatchWeb(SnatchWeb snatchWeb) {
		this.snatchWeb = snatchWeb;
	}
	public SnatchGame getSnatchGame() {
		return snatchGame;
	}
	public void setSnatchGame(SnatchGame snatchGame) {
		this.snatchGame = snatchGame;
	}
	
	public Long getVersion() {
		return version;
	}
	public void setVersion(Long version) {
		this.version = version;
	}
	public int getSumPage() {
		return sumPage;
	}
	public void setSumPage(int sumPage) {
		this.sumPage = sumPage;
	}
	public Long getInterval() {
		return interval;
	}
	public void setInterval(Long interval) {
		this.interval = interval;
	}
	public String itemOnlyCode(){
		StringBuffer sb = new StringBuffer();
		sb.append(this.snatchWeb.getWebCode());

		sb.append("_");
		sb.append(this.snatchGame.getGameCode());

		sb.append("_");
		sb.append(this.itemName);

		sb.append("_");
		sb.append(this.itemType);

		return sb.toString();
	}
	
	/*数据改变时间 该值用于保存数据的改变如果该值为空，则表示数据很久没被更新到了。赛事赔率将会被移除*/
	public void setDataChangeTiem(Long dataChangeTiem) {
		if(this.dataChangeTiem!=null){
			this.interval = dataChangeTiem - this.dataChangeTiem;
		}
		this.dataChangeTiem = dataChangeTiem;
	}
	
	public boolean haveNode(String nodeOnlycode){
		if(null == nodelist) return false;
		for(NodeSnatch nodeSnatch : nodelist){
			if(nodeSnatch.getNodeOnlyCode().equals(nodeOnlycode)){
				return true;
			}
		}
		return false;
	}
	
	public void updateNodeTime(String nodeOnlycode){
		if(null == nodelist) return;
		for(NodeSnatch nodeSnatch : nodelist){
			if(nodeSnatch.getNodeOnlyCode().equals(nodeOnlycode)){
				nodeSnatch.setUpdateTiem(System.currentTimeMillis());
			}
		}
	}
	
	
}
